package inits

import (
	"context"
	"github.com/go-redis/redis/v8"
	"log"
	"video_08_05/config"
	"video_08_05/global"
)

func InitRedis() {

	r := config.Conf.Redis

	global.RDB = redis.NewClient(&redis.Options{
		Addr:     r.Addr,
		Password: r.Password, // no password set
		DB:       r.DB,       // use default DB
	})

	err := global.RDB.Ping(context.Background()).Err()
	if err != nil {
		panic(err)
	}

	log.Println("redis init success")

}
